#include <func.h>
typedef struct 
{
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}args_t;

void *func(void* p)
{
    args_t *data = (args_t *)p;
    printf("child thread: lock and wait\n");
    pthread_mutex_lock(&data->mutex);
    pthread_cond_wait(&data->cond,&data->mutex);
    pthread_mutex_unlock(&data->mutex);
    printf("child thread:wait over\n");
}

int main(int argc,char **argv)
{
    pthread_t pthid;
    args_t data;
    pthread_mutex_init(&data.mutex,NULL);
    pthread_cond_init(&data.cond,NULL);

    pthread_create(&pthid,NULL,func,&data);
    sleep(1);
    printf("main thread: give signal\n");
    pthread_cond_signal(&data.cond);

    long ret;
    pthread_join(pthid,(void**)ret);
    printf("good join, ret %ld\n",ret);
    return 0;
}

